import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
import {Office} from "../../models/office";
import {showToast} from "../../util/ui";

const app = getApp()
Page({
  data: {
    swiperArr: [{
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.pinda.net.cn%2Fpic%2Fallimg%2Fcopyright%2Fimg%2Fb7a8c2c91_2.jpg&refer=http%3A%2F%2Fwww.pinda.net.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1648281343&t=26bc604782069ab37e39b20020e5f214',
      id: '001'
    }, {
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimagepphcloud.thepaper.cn%2Fpph%2Fimage%2F67%2F86%2F63.jpg&refer=http%3A%2F%2Fimagepphcloud.thepaper.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1648281343&t=43729fbf9a8bdbad03582af36d3cd590',
      id: '002'
    }, {
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp1.itc.cn%2Fq_70%2Fimages03%2F20211209%2F475f0bc290774782aa24bb65bf3b49c2.png&refer=http%3A%2F%2Fp1.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1648281343&t=813c2d2ca48e16f903702dbbdef94c77',
      id: '003'
    }, {
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.npazone.com%2FUploads%2Fnews%2F2020-01-16%2F1579165297586998.jpg&refer=http%3A%2F%2Fwww.npazone.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1648281443&t=55920c3c362a5a81f4faa8a8f7512a6f',
      id: '004'
    }],
    caseNums: 0,
    peopleNums: 0,
    query: {
      pageNum: 1,
      pageSize: 10
    },
    showLoading: true
  },
  onLoad(options) {
    app.getToken()
      .then(res => {
        if (+res.code === 200) {
          wx.setStorageSync('token', res.data)
          Office.doApiGetOfficeInfo(this.data.query)
            .then(officeRes => {
              const data = officeRes.rows[0]
              this.setData({
                caseNums: data.caseNumber,
                peopleNums: data.peopleOnline,
                showLoading: false
              })
            })
        }
      })
      .catch(() => {
        showToast('网络异常')
      })
  },
  // 点击律所介绍
  handleTagOne() {
    wx.switchTab({
      url: '../about/about'
    })
  },

  // 点击律所精英
  handleTagTwo() {
    wx.navigateTo({
      url: '../elite/elite'
    })
  },

  // 点击成功案例
  handleTagThree() {
    wx.switchTab({
      url: '../successful/successful'
    })
  },

  // 点击律所荣誉
  handleTagFour() {
    wx.navigateTo({
      url: '../honor/honor'
    })
  },

  // 一键通话
  handleConver() {
    wx.makePhoneCall({
      phoneNumber: '10010123'
    }).then(res => {
      Toast('正在为你跳转到拨号界面');
    }).catch(() => {
      Toast('取消了一键通话');
    })

  },

  // 预约咨询
  handleTalking() {
    wx.navigateTo({
      url: '../pay/pay'
    })
  },
  onShareAppMessage() {}
})
